<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>页面可能丢了</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    .box{
      width: 400px;
      height: 600px;
      background-color: #f4f4f4;
      border-radius: 10px;
      margin: 100px auto;
    }
    h3{
      padding: 50PX 20PX;
    }
    a{
      display: inline-block;
      font-size: 16px;
      color: #333;
      font-weight: 600;
      padding-left: 20px;
      text-decoration: none;
    }
    #title{
      display: inline-block;
    }
  </style>
</head>

<body>
  <div class="box">
      <h3>页面丢了</h3>
      <a href="/">去首页</a>
      <div id="title">3...</div>
  </div>
  

  <script>
    let title = document.getElementById('title')
    // 计数器
    let count = 3
    title.innerHTML = count
    // 定时器
    setInterval(() => {
      if (count == 0) {
        location.href = '/'
      }
      title.innerHTML = count
      count--
    }, 1000);
  </script>
</body>

</html>